Skip to content

feat: Glossaries #3003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 96 commits into
base: glossaries
Choose a base branch
from
Open

feat: Glossaries #3003

wants to merge 96 commits into from

Conversation

Anty0
Copy link
Collaborator

@Anty0 Anty0 commented Mar 21, 2025

Implements #2969 and #1418
Requires https://github.com/tolgee/translator/pull/32 to be deployed.
Expects these links to be valid documentation links:

Summary by CodeRabbit

  • New Features

    • Added extensive glossary management capabilities: create, update, delete glossaries and terms with translations in organizations.
    • Introduced glossary term highlighting within translation views and project panels.
    • Implemented multi-language support for glossaries with language selection components.
    • Added batch operations and infinite scrolling for glossary terms and projects.
    • Integrated glossary features into API, UI, and role-based permissions, controlled by feature flags.
    • Added new endpoints for glossary languages, term translations, and project-level glossary highlights.
  • Bug Fixes

    • Enhanced search and selection components to avoid redundant fetches and improve key handling.
  • Documentation

    • Expanded testing and contribution guidelines, including translation key usage and branch naming conventions.
  • Tests

    • Added comprehensive end-to-end and integration tests covering glossary CRUD operations, permissions, highlighting, and UI behavior.
  • Chores

    • Refactored UI layout components and type definitions for better maintainability.
    • Consolidated OpenAPI extension handling and suppressed autowiring inspection warnings across backend components.

@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch 2 times, most recently from b6ac50b to 1bfd767 Compare March 27, 2025 15:21
Copy link

coderabbitai bot commented Apr 1, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces a comprehensive glossary management feature across the backend, frontend, and end-to-end testing layers. It adds new database tables, backend entities, repositories, services, and API endpoints for managing glossaries, terms, and translations. The frontend implements glossary UI components, routes, hooks, and validation schemas, with integrated permissions and feature gating. Extensive end-to-end Cypress tests are included to validate glossary creation, editing, deletion, navigation, and permissions.

Changes

File(s) / Area Change Summary
Backend: Database & Entities Added new tables for glossaries, glossary-project relations, terms, and term translations; introduced entities Glossary, GlossaryTerm, GlossaryTermTranslation; updated Organization and Project models for glossary associations.
Backend: Repositories & Services Introduced repositories and services for glossaries, glossary terms, and translations, supporting CRUD, assignment, search, highlights, and translation management; implemented feature flag checks and transactional operations.
Backend: API Controllers & DTOs (EE & OSS) Added REST controllers for glossaries, glossary languages, glossary terms, term translations, and glossary term highlights; exposed endpoints for CRUD, pagination, search, batch operations, and language listing; added HATEOAS model assemblers and DTOs.
Backend: Machine Translation Integrated glossary terms into machine translation metadata; added provider interface and OSS/EE implementations; enhanced translation API request to include glossary terms.
Backend: Test Data Builders & Tests Added test data builders for glossaries, glossary terms, and translations; created integration tests for API endpoints and permissions.
Backend: Miscellaneous Added glossary feature flag, glossary-related error codes, OpenAPI annotation consolidation, and multiple suppression annotations for Spring autowiring warnings.
Frontend: Glossary UI Components Implemented React components for glossary listing, creation, editing, viewing, term management, translations, tags, batch toolbar, empty states, and previews; added context providers, hooks, and selection management utilities.
Frontend: Routing & Context Added glossary routes within organization scope; introduced context providers and hooks for glossary data and term highlights.
Frontend: Validation & Constants Added Yup validation schemas for glossary and term forms; extended link constants, types, and data-cy selectors for glossary features.
Frontend: Layout & Common Components Refactored layout components to support glossary screens; introduced header bar, grid-based containers, and improved list and select components.
Frontend: Translation Visual & Tools Panel Enhanced translation visual to support glossary term highlights; integrated glossary panel into translation tools with conditional display and counts.
Frontend: Miscellaneous Updated project menu and language icon list components; enabled React Strict Mode globally.
E2E Cypress: Test Data & Utilities Extended test data generators and lookup functions to support glossaries and glossary terms.
E2E Cypress: Compounds & Page Objects Added page object classes for glossaries, glossary terms, and dialogs to encapsulate UI interactions and testing workflows.
E2E Cypress: Test Suites Implemented comprehensive test suites for glossary creation, editing, deletion, navigation, term management, translation editing, highlighting, and permissions.
Documentation & Guidelines Updated contribution guidelines with glossary-related testing and branch naming recommendations; added translation key usage instructions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant API
    participant DB

    User->>WebApp: Navigates to Organization Glossaries
    WebApp->>API: GET /v2/organizations/{orgId}/glossaries
    API->>DB: Query glossaries for organization
    DB-->>API: Glossary list
    API-->>WebApp: Glossary list
    WebApp->>User: Displays glossary list

    User->>WebApp: Creates/Edits Glossary
    WebApp->>API: POST/PUT /v2/organizations/{orgId}/glossaries
    API->>DB: Insert/Update glossary
    DB-->>API: Success
    API-->>WebApp: Created/Updated glossary
    WebApp->>User: Shows confirmation

    User->>WebApp: Views Glossary Terms
    WebApp->>API: GET /v2/organizations/{orgId}/glossaries/{glossaryId}/terms
    API->>DB: Query glossary terms
    DB-->>API: Term list
    API-->>WebApp: Term list
    WebApp->>User: Displays term list

    User->>WebApp: Adds/Edits Term
    WebApp->>API: POST/PUT /v2/organizations/{orgId}/glossaries/{glossaryId}/terms
    API->>DB: Insert/Update term (+ translation)
    DB-->>API: Success
    API-->>WebApp: Created/Updated term
    WebApp->>User: Shows confirmation

    User->>WebApp: Edits Term Translation
    WebApp->>API: POST /v2/organizations/{orgId}/glossaries/{glossaryId}/terms/{termId}/translations
    API->>DB: Insert/Update translation
    DB-->>API: Success
    API-->>WebApp: Updated translation
    WebApp->>User: Shows updated translation

    User->>WebApp: Uses translation tools
    WebApp->>API: GET /v2/projects/{projectId}/glossary-highlights?text=...&languageTag=...
    API->>DB: Find matching glossary terms
    DB-->>API: Highlights
    API-->>WebApp: Highlights
    WebApp->>User: Renders highlights in translation visual
Loading

Poem

🐇
In the garden of code, new glossaries bloom,
With terms and translations, dispelling the gloom.
From backend to frontend, connections abound,
With highlights and tooltips, new meanings are found.
Tests hop along, ensuring all’s right—
Hooray for new words, and features so bright!
📝✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch from e4846cf to 81aa318 Compare April 1, 2025 16:04
@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch 2 times, most recently from 33d4b96 to 19c8f9e Compare April 14, 2025 13:20
@JanCizmar JanCizmar changed the base branch from main to glossaries April 22, 2025 12:40
@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch from 7eb3a67 to 0487aaa Compare April 29, 2025 13:57
@Anty0 Anty0 changed the base branch from glossaries to main April 29, 2025 14:02
@Anty0 Anty0 changed the base branch from main to glossaries April 29, 2025 14:02
@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch from 0487aaa to 8ee8c4f Compare April 30, 2025 13:22
@Anty0 Anty0 changed the base branch from glossaries to main April 30, 2025 13:24
@Anty0 Anty0 changed the base branch from main to glossaries April 30, 2025 13:24
@Anty0 Anty0 force-pushed the jirikuchynka/glossaries branch from b58d617 to 872dda5 Compare May 12, 2025 12:10
@Anty0 Anty0 linked an issue May 20, 2025 that may be closed by this pull request
@Anty0
Copy link
Collaborator Author

Anty0 commented May 20, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anty0
Copy link
Collaborator Author

Anty0 commented May 20, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anty0
Copy link
Collaborator Author

Anty0 commented May 20, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anty0
Copy link
Collaborator Author

Anty0 commented May 20, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anty0 Anty0 marked this pull request as ready for review May 20, 2025 18:55
@Anty0
Copy link
Collaborator Author

Anty0 commented May 20, 2025

@coderabbitai review

Copy link

coderabbitai bot commented May 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Anty0 Anty0 requested a review from JanCizmar May 20, 2025 19:21
Copy link
Contributor

@JanCizmar JanCizmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! 👍

Thanks a lot!

@@ -72,6 +72,11 @@ class ActivityRevision : java.io.Serializable {
*/
var projectId: Long? = null

// /**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out, todo

var name: String = "",
@ActivityLoggedProp
@Column(nullable = false)
var baseLanguageTag: String? = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index on the tag?

var terms: MutableList<GlossaryTerm> = mutableListOf()

@ManyToOne(optional = true, fetch = FetchType.LAZY)
lateinit var organizationOwner: Organization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index on organization?

var description: String? = null,
) : StandardAuditModel() {
@ManyToOne
lateinit var glossary: Glossary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index?

var text: String? = null,
) : StandardAuditModel() {
@ManyToOne
lateinit var term: GlossaryTerm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index?


import io.tolgee.ee.api.v2.hateoas.model.glossary.GlossaryTermModel

data class GlossaryTermHighlightDto(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create model and model assembler instead.

@Schema(example = "cs-CZ", description = "Language tag according to BCP 47 definition")
@field:NotBlank
@field:Size(max = 20)
@field:Pattern(regexp = "^[^,]*$", message = "can not contain coma")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment about tag.

@field:Size(max = 500)
var description: String? = null

var flagNonTranslatable: Boolean? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the props.

gtt.term.glossary.deletedAt is null
""",
)
fun findByFirstWordLowercasedAndLanguageTagAndAssignedProjectIdAndOrganizationId(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you provide the query, You don't have to use such a long method name :D

}

@Transactional
override fun glossaryTermsFor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should be named getGlossaryTerms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Glossaries
2 participants